<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      fit
      highlight-current-row>
      <el-table-column
        prop="nickname"
        label="姓名"
        sortable
        width="180">
      </el-table-column>
      <el-table-column
        prop="time"
        label="日期"
        width="180"
        sortable>
      </el-table-column>
      <el-table-column
        prop="msg"
        label="留言"
        >
      </el-table-column>
      <el-table-column
        label="操作"
        width="180">
        <template slot-scope="scope">
          <el-button
            type="text"
            icon="el-icon-delete"
            @click="handledel(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
  import { getusermsg,delusermsg } from '@/api/wxqiandao'
    export default {
      name: "usermsg",
      data() {
          return{
            list: null,
            listLoading: true
          }
      },
      created() {
        this.getlist()
      },
      methods:{
        getlist(){
          getusermsg().then(response => {
            this.list = response.data.list;
            this.listLoading = false;
          })
        },
        handledel(index, row){
          delusermsg(row.id).then(response =>{
            this.$message(response.msg);
            this.getlist();
          })
        }
      }
    }
</script>

<style scoped>

</style>
